{extend name="../public/header" /}
{block name="body"}
<body>
{include file="../public/top" uname="$roleInfo.uname" lv="$roleInfo.ulv" ls="$roleInfo.uyxb" jp="$roleInfo.uczb" /}
<div class="subject main">
    <div class="layui-row">
        <div class="content">
            <div class="current">
                <span class="position">{$roleInfo.map.mname}</span>
                <span class="state">{if $roleInfo.map.ispvp==0}[安全区]{else/}[PVP]{/if}</span>
                <span class="info ajax-goto" data-url="{:url('home/index')}">返回</span>
            </div>
            <div class="npc">
                <div class="layui-panel">
                    <div style="padding:10px;">
                        <span class="layui-breadcrumb" lay-separator="|">
                            <a class="ajax-goto" data-url="{:url('package/myEquip')}">装备</a>
                            <a class="ajax-goto" data-url="{:url('package/myProp')}">道具</a>
                            <a class="ajax-goto" data-url="{:url('package/myDrug')}">丹药</a>
                            <a class="ajax-goto" data-url="{:url('package/myTask')}">任务</a>
                        </span>
                        <div class="layui-row layui-col-space10 shop" style="border: #D5CBCB 1px solid;">
                            {volist name="list" id="vo"}
                            <div class="layui-col-xs4">
                                <div class="grid-demo">
                                    <div class="shop-title">{$vo.ypname} x{$vo.ypsum}</div>
                                    <div class="shop-des">{$vo.ypinfo}</div>
                                    <div class="shop-lable">
                                        <a class="layui-btn layui-btn-xs layui-btn-primary layui-border-blue ajax-act" data-act="lattice" data-id="{$vo.id}">技</a>
                                        <a class="layui-btn layui-btn-xs layui-btn-primary layui-border-blue ajax-act" data-act="eat" data-id="{$vo.id}">食</a>
                                        <a class="layui-btn layui-btn-xs layui-btn-primary layui-border-blue ajax-act" data-act="lose" data-id="{$vo.id}">丢</a>
                                    </div>
                                </div>
                            </div>
                            {/volist}
                            {for start="1" end="$surplusLattice"}
                            <div class="layui-col-xs4">
                                <div class="grid-demo" style="height:90px;line-height:90px;background-color: #EFEFEF;">空</div>
                            </div>
                            {/for}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
{/block}
{block name="script"}
<script>
    layui.use(['jquery', 'form', 'layajax', 'upload', 'flow', 'element'], function () {
        var $ = layui.jquery
            , layajax = layui.layajax
            , upload = layui.upload
            , element = layui.element
            , flow = layui.flow
            , form = layui.form;

        $('.ajax-act').on('click', function () {
            var act = $(this).data('act');
            var id = $(this).data('id');

            console.log('act', act, 'id', id);

            var map = {};
            map['act'] = act;
            map['id'] = id;

            $.post("{:url('drugAct')}", map, function (res) {
                if (res.code == undefined) {
                    console.log('res为json字符串', res);
                    res = JSON.parse(res);
                } else {
                    console.log('res为json对象', res);
                }
                if (res.code == 1) {
                    layer.msg(res.msg, {icon: 1, time: 1000}, function (index) {
                        if (res.data.url != '' && res.data.url != undefined) {
                            window.location.href = res.data.url;
                        } else {
                            location.reload();
                        }
                    });
                } else {
                    layer.msg(res.msg);
                }
            });

        });

        form.render();
    });
</script>
{/block}